function loaded() {
    Zepto('.loading').hide();
    Zepto('#wrap').eq(0).css('opacity', 1);
    // no_input_cz();
    // Wxweinre("script");  //移动端调试要开启
    // auto_refresh(8000);
   // var num=0;
   // var timer=setInterval(function(){
   //   no_input_cz();
   //   num++;
   //   if(num==3000){
   //    clearInterval(timer);
   //   }
   // },1);
}

function no_input_cz() {
    Zepto("#minibody").css({
        "width": Zepto(window).width(),
        "height": Zepto(window).height()
    });
}


function Wxweinre(ele) {
    var myScript = document.createElement(ele);
    myScript.type = "text/javascript";
    myScript.src = "http://10.10.10.159:9973/target/target-script-min.js#anonymous";
    document.body.appendChild(myScript);
}


function show_tc(ele1, ele2, flag) {
    if (flag == 0) {
        Zepto(ele1).bind("touchstart", function() {
            Zepto(ele2).show();
        });
    } else if (flag == 1) {
        Zepto(ele1).bind("touchend", function() {
            setTimeout(function() {
                Zepto(ele2).hide();
            }, 400);
        });
    }

}



//获取根路径
function getRootPath_web() {
            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
            var curWwwPath = window.document.location.href;
            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            var localhostPaht = curWwwPath.substring(0, pos);
            //获取带"/"的项目名，如：/uimcardprj
            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
            return (localhostPaht + projectName+"/");
}

//获取URL中指定参数的值
function getQueryVariable(variable){
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}


function onlyWx(){
    // 对浏览器的UserAgent进行正则匹配，不含有微信独有标识的则为其他浏览器  
    var useragent = navigator.userAgent;  
    if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {  
        // 这里警告框会阻塞当前页面继续加载  
        alert('已禁止本次访问：您必须使用微信内置浏览器访问本页面！');  
        // 以下代码是用javascript强行关闭当前页面  
        var opened = window.open('about:blank', '_self');  
        opened.opener = null;  
        opened.close();  
    }  
}


//图形验证码

/*
// 调用
// tx_yzm();
// var verifyCode = new GVerify("txm_qy");
// document.getElementById("zhc_but").onclick = function(){
//     var res = verifyCode.validate(document.getElementById("code_input").value);
//     if(res){
//         // alert("验证正确");
//     }else{
//         Zepto(".error").text("图形验证码错误！");
//     }
// }


*/

function tx_yzm(){
var size = 4;//设置验证码长度
function GVerify(options) { //创建一个图形验证码对象，接收options对象为参数
this.options = { //默认options参数值
    id: "", //容器Id
    canvasId: "verifyCanvas", //canvas的ID
    width: "100", //默认canvas宽度
    height: "30", //默认canvas高度
    type: "number", //图形验证码默认类型blend:数字字母混合类型、number:纯数字、letter:纯字母
    code: "",
}
if(Object.prototype.toString.call(options) == "[object Object]"){//判断传入参数类型
    for(var i in options) { //根据传入的参数，修改默认参数值
        this.options[i] = options[i];
    }
}else{
    this.options.id = options;
}

this.options.numArr = "0,1,2,3,4,5,6,7,8,9".split(",");
this.options.letterArr = getAllLetter();

this._init();
this.refresh();
}

GVerify.prototype = {
/**版本号**/
version: '1.0.0',

/**初始化方法**/
_init: function() {
    var con = document.getElementById(this.options.id);
    var canvas = document.createElement("canvas");
    this.options.width = con.offsetWidth > 0 ? con.offsetWidth : "100";
    this.options.height = con.offsetHeight > 0 ? con.offsetHeight : "30";
    canvas.id = this.options.canvasId;
    canvas.width = this.options.width;
    canvas.height = this.options.height;
    canvas.style.cursor = "pointer";
    canvas.innerHTML = "您的浏览器版本不支持canvas";
    con.appendChild(canvas);
    var parent = this;
    canvas.onclick = function(){
        parent.refresh();
    }
},

/**生成验证码**/
refresh: function() {
    this.options.code = "";
    var canvas = document.getElementById(this.options.canvasId);
    if(canvas.getContext) {
        var ctx = canvas.getContext('2d');
    }else{
        return;
    }
    
    ctx.textBaseline = "middle";

    ctx.fillStyle = randomColor(180, 240);
    ctx.fillRect(0, 0, this.options.width, this.options.height);

    if(this.options.type == "blend") { //判断验证码类型
        var txtArr = this.options.numArr.concat(this.options.letterArr);
    } else if(this.options.type == "number") {
        var txtArr = this.options.numArr;
    } else {
        var txtArr = this.options.letterArr;
    }

    for(var i = 1; i <=size; i++) {
        var txt = txtArr[randomNum(0, txtArr.length)];
        this.options.code += txt;
        ctx.font = randomNum(this.options.height/2, this.options.height) + 'px SimHei'; //随机生成字体大小
        ctx.fillStyle = randomColor(50, 160); //随机生成字体颜色        
        ctx.shadowOffsetX = randomNum(-3, 3);
        ctx.shadowOffsetY = randomNum(-3, 3);
        ctx.shadowBlur = randomNum(-3, 3);
        ctx.shadowColor = "rgba(0, 0, 0, 0.3)";
        var x = this.options.width / (size+1) * i;
        var y = this.options.height / 2;
        var deg = randomNum(-30, 30);
        /**设置旋转角度和坐标原点**/
        ctx.translate(x, y);
        ctx.rotate(deg * Math.PI / 180);
        ctx.fillText(txt, 0, 0);
        /**恢复旋转角度和坐标原点**/
        ctx.rotate(-deg * Math.PI / 180);
        ctx.translate(-x, -y);
    }
    /**绘制干扰线**/
    for(var i = 0; i < 16; i++) {
        ctx.strokeStyle = randomColor(40, 180);
        ctx.beginPath();
        ctx.moveTo(randomNum(0, this.options.width), randomNum(0, this.options.height));
        ctx.lineTo(randomNum(0, this.options.width), randomNum(0, this.options.height));
        ctx.stroke();
    }
    /**绘制干扰点**/
    for(var i = 0; i < this.options.width/4; i++) {
        ctx.fillStyle = randomColor(0, 255);
        ctx.beginPath();
        ctx.arc(randomNum(0, this.options.width), randomNum(0, this.options.height), 1, 0, 2 * Math.PI);
        ctx.fill();
    }
},

/**验证验证码**/
validate: function(code){
    var code = code.toLowerCase();
    var v_code = this.options.code.toLowerCase();
    if(code == v_code){
        return true;
    }else{
        this.refresh();
        return false;
    }
}
}
/**生成字母数组**/
function getAllLetter() {
var letterStr = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
var letterStr = "0,1,2,3,4,5,6,7,8,9";
return letterStr.split(",");
}
/**生成一个随机数**/
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
/**生成一个随机色**/
function randomColor(min, max) {
var r = randomNum(min, max);
var g = randomNum(min, max);
var b = randomNum(min, max);
return "rgb(" + r + "," + g + "," + b + ")";
}
window.GVerify = GVerify;
}


/*
 * 利用canvas 对图片进行压缩 
 * @param m_this当前对象
 * @param id展示图片id
 * @param wid压缩后宽度
 * @param quality压缩质量 
 * */
function cutImageBase64(m_this, id, wid, quality) {
    var file = m_this.files[0];
    var URL = window.URL || window.webkitURL;
    var blob = URL.createObjectURL(file);
    var base64;
    var img = new Image();
    img.src = blob;
    img.onload = function() {
        var that = this;
        //生成比例
        var w = that.width,
            h = that.height,
            scale = w / h;
        w = wid || w;
        h = w / scale;
        //生成canvas
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        $(canvas).attr({
            width: w,
            height: h
        });
        ctx.drawImage(that, 0, 0, w, h);
        // 生成base64            
        base64 = canvas.toDataURL('image/jpeg', quality || 0.8);
        $(id).attr('src', base64);
    };
}
//调用 
// $(id).on('change',function(){
//     var m_this = this;
//     cutImageBase64(m_this,'#com_ImgPr03',400,0.8);  
// })


autoH();
window.addEventListener("orientationchange", autoH);
window.addEventListener("resize", autoH);

function autoH() {
    var html = document.querySelector("html");
    var w = html.getBoundingClientRect().width;

    //首页热门活动高度适配
    //var scrollHeight = $('#scrollDiv li').outerHeight(true);
    //$("#scrollDiv").height(scrollHeight*3-10);

    //举荐结果页图片高度适配
    var per = 175 / 224;
    $('#xqff_jjjg_se_2 .item_wrap img').each(function() {
        $(this).height($(this).width() / per);
    });

    var per = 364 / 211;
    $('.xqff_zqjp_se_3 .lists img').each(function() {
        $(this).height($(this).width() / per);
    });

    var per = 270 / 178;
    $('.xqff_zqmp_se_1 .lists img').each(function() {
        $(this).height($(this).width() / per);
    });


}


function wrap_btn(ele){
    Zepto(ele).each(function(){
        Zepto(this).wrap('<div class="parent_btn size100"></div>');
        var cla=Zepto(this).attr("class");
        Zepto(this).parent().attr("class",cla+"parent_btn size100");
        Zepto(this).parent().attr("style","background:url("+Zepto(this).attr("src")+");height:0.826667rem;"+Zepto(this).attr("style")+"");
        Zepto(this).parent().attr("data-clipboard-action",Zepto(this).attr("data-clipboard-action"));
        Zepto(this).parent().attr("data-clipboard-target",Zepto(this).attr("data-clipboard-target"));
        Zepto(this).parent().attr("onclick",Zepto(this).attr("onclick"));
        Zepto(this).remove();
    });
    
}


function pagesw(hdfs, hddx, ele, t, qx, dire) {
    if (Zepto("#pages").length != 0) {
        hddx = new pageSwitch(ele, {
            duration: t,
            start: 0,
            direction: dire,
            loop: false,
            ease: qx,
            transition: hdfs,
            freeze: false,
            mouse: false,
            mousewheel: false,
            arrowkey: true
        });
        hddx.on('after', function() {
            //    Zepto('#pages .wpage').each(function(){
            // if(Zepto(this).css('display')=='block'){
            //   inde=Zepto(this).index();
            //    if(inde==6){
            //        Zepto('.gd').hide();
            //        Zepto('.sj').hide();
            //    }else{
            //        Zepto('.gd').show();
            //        Zepto('.sj').show();
            //    }

            // }
        });
    }





}



function sel_change(ele, s_ele) {
    if (Zepto(ele).length != 0) {
        var loc = document.querySelector(ele);
        loc.onchange = function() {
            Zepto(s_ele).text(jQuery(ele + " option:selected").text());
        };
    }

}


function sexl() {
    Zepto(".cx_con").bind("touchstart", function() {
        if (Zepto(this).attr("flag") != 0) {
            Zepto(".cx_con").removeClass("cked");
            Zepto(this).addClass("cked");
        }

    });
}


function sale_chioce() {
    Zepto(".cx_con1").tap(function() {
        if (Zepto(this).attr("flag") != 0) {
            Zepto(".zfj").text("￥6799");
        }
    });
    Zepto(".cx_con2").tap(function() {
        if (Zepto(this).attr("flag") != 0) {
            Zepto(".zfj").text("￥10799");
        }

    });
    Zepto(".cx_con3").tap(function() {
        if (Zepto(this).attr("flag") != 0) {
            Zepto(".zfj").text("￥6299");
        }

    });

    Zepto(".cx_con4").tap(function() {
        if (Zepto(this).attr("flag") != 0) {
            Zepto(".zfj").text("￥9566");
        }

    });
}


/*倒计时*/
function djs(ele, time, djs_pl) {
    var tim_num = time;
    var tts=Zepto(ele).text();
    Zepto(ele).addClass("hd");
    Zepto(ele).text((time-1)+"s");
    tim_num = tim_num - 1;
    var timer = setInterval(function() {
        tim_num = tim_num - 1;
        Zepto(ele).text(tim_num + "s");
        if (tim_num == 0) {
            clearInterval(timer);
            Zepto(ele).text(tts);
            Zepto(ele).removeClass("hd");
        }
    }, djs_pl);
}

function timerDjs(intDiff,func,date,times){
	  var timer=window.setInterval(function(){
	  /*var day=0,
		  hour=0,
		  minute=0,
		  second=0;//时间默认值        
	  if(intDiff >= 0){
		  // day = Math.floor(intDiff / (60 * 60 * 24));
		  // hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
		  minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
		  second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
	  }else{
		  clearInterval(timer);
		  func();
	  }
	  if (minute <= 9) minute = '0' + minute;
	  if (second <= 9) second = '0' + second;*/
	 /* intDiff--;*/
	 
     //1.获取当前日期


          var date2=new Date();

          let difftime = (date - date2)/1000;
          let res = getTime(difftime-times);

          
          // $('.day_show').html(day+"天");
          // $('.hour_show').html('<s id="h"></s>'+hour+'时');
          $('.minute_show').html(res[1]);
          $('.second_show').html(res[2]);
		  
		  if(difftime<=0){
			  func();
			  clearInterval(timer);
		  }

	  }, 1000);
}
function getTime(time) {
    // 转换为式分秒
    let h = parseInt(time / 60 / 60 % 24)
    h = h < 10 ? '0' + h : h
    let m = parseInt(time / 60 % 60)
    m = m < 10 ? '0' + m : m
    let s = parseInt(time % 60)
    s = s < 10 ? '0' + s : s
    // 作为返回值返回
    return [h, m, s]
}

function auto_refresh(time) {
    setInterval(function() {
        window.location.reload();
    }, time);

}

function toggle_tap() {
    var flag = 0;
    Zepto(".cd_icon").tap(function() {
        if (flag == 0) {
            gz_ani(280);
            Zepto(".cd_icons").hide();
            setTimeout(function() { Zepto(".cdzi").show(); }, 280 * 3);
            flag = 1;
        } else {
            Zepto(".cdzi").hide();
            Zepto(".cd_icons").show();
            flag = 0;
        }
    });

}


function gz_ani(time) {
    Zepto(".xg1").addClass("gz_ani");
    setTimeout(function() {
        Zepto(".xg2").addClass("gz_ani");
    }, time);
    setTimeout(function() {
        Zepto(".xg3").addClass("gz_ani");
    }, time * 2);
    setTimeout(function() {
        Zepto(".xgx").removeClass("gz_ani");
    }, time * 3);

}


function qq_ani(time, flag, flag2) {
    if (Zepto(flag).length != 0) {
        if (flag2 == true) {
            Zepto(".erw,.cd_iconl").hide();
            Zepto(".gz2").addClass("gz_ani2");
            setTimeout(function() { Zepto(".gz1").addClass("gz_ani2"); }, time * 2);
            setTimeout(function() { Zepto(".qq1").addClass("gz_anis"); }, time * 6);
            setTimeout(function() { Zepto(".qq2").addClass("gz_anis"); }, time * 7);
            setTimeout(function() { Zepto(".qq3").addClass("gz_anis"); }, time * 8);
            setTimeout(function() { Zepto(".car").addClass("car_ani"); }, time * 8);
            setTimeout(function() { Zepto(".qq4").addClass("gz_anis"); }, time * 9);
            setTimeout(function() { Zepto(".qq5").addClass("gz_anis"); }, time * 10);
            setTimeout(function() { Zepto(".qq6").addClass("gz_anis"); }, time * 11);
            setTimeout(function() { Zepto(".qq7").addClass("gz_anis"); }, time * 12);
            setTimeout(function() { Zepto(".qq8").addClass("gz_anis"); }, time * 13);
            setTimeout(function() { Zepto(".qq9").addClass("gz_anis"); }, time * 14);
            setTimeout(function() { Zepto(".qq10").addClass("gz_anis"); }, time * 15);
            setTimeout(function() { Zepto(".qq11").addClass("gz_anis"); }, time * 16);
            setTimeout(function() { Zepto(".qq12").addClass("gz_anis"); }, time * 17);
            setTimeout(function() { Zepto(".qq13").addClass("gz_anis"); }, time * 18);
            setTimeout(function() { Zepto(".fd_cons2,.cd_iconr,.gz_conr").show(); }, time * 25);
        } else {
            Zepto(".fd_cons2,.cd_iconr,.gz_conr").show();
        }
    }
}

function qqr_anii(time, flag, flag2) {
    if (Zepto(flag).length != 0) {
        if (flag2 == true) {
            Zepto(".qqr1").addClass("gz_anir");
            Zepto(".carr2").addClass("car_anir");
            Zepto(".erw,.erws").hide();
            setTimeout(function() { Zepto(".qqr1").addClass("gz_anir"); }, time * 1);
            setTimeout(function() { Zepto(".qqr2").addClass("gz_anir"); }, time * 2);
            setTimeout(function() { Zepto(".qqr3").addClass("gz_anir"); }, time * 3);
            setTimeout(function() { Zepto(".qqr4").addClass("gz_anir"); }, time * 4);
            setTimeout(function() { Zepto(".qqr5").addClass("gz_anir"); }, time * 5);
            setTimeout(function() { Zepto(".qqr6").addClass("gz_anir"); }, time * 6);
            setTimeout(function() { Zepto(".qqr7").addClass("gz_anir"); }, time * 7);
            setTimeout(function() { Zepto(".qqr8").addClass("gz_anir"); }, time * 8);
            setTimeout(function() { Zepto(".fd_cons1,.cd_iconl").show(); }, time * 15);
        } else {
            Zepto(".erw,.erws,.tgsm").hide();
            Zepto(".fd_cons1,.cd_iconl").show();
        }

    }
}

function playmus(srcb, src) {
    var mus = document.getElementById("jfmus");
    mus.play();
    var flag = 0;
    Zepto(".music_icon").tap(function() {
        if (flag == 0) {
            mus.pause();
            Zepto(this).attr("src", srcb);
            flag = 1;
        } else {
            mus.play();
            Zepto(this).attr("src", src);
            flag = 0;
        }
    });
}

function tgsm() {
    setTimeout(function() {
        if (islength(".tgsm")) {
            Zepto(".tgsm").show();
        }
    }, 6000);
}

function islength(ele) {
    if (Zepto(ele).length != 0) {
        return true;
    } else {
        return false;
    }
}


function xf_xs(ele, time) {
    setTimeout(function() {
        Zepto(ele).hide();
    }, time);
}



function loadedIscrollo(sfzx, ele, myScroll, hs, vs,bounc) {
    if (Zepto(sfzx).length != 0) {

        myScroll = new iScroll(ele, {
            hScroll: hs,
            vScroll: vs,
            checkDOMChanges: true,
            topOffset: 0,
            x: 0,
            y: 0,
            hScrollbar: false,
            vScrollbar: false,
            fadeScrollbar: false,
            scrollbarClass: '',
            zoom: false,
            zoomMax: 4,
            zoomMax: 1,
            bounce: bounc,
            momentum: true,
            hideScrollbar: true});
        
    }
	// myScroll.scrollTo(myScroll.maxScrollX,0,0);

}


//大转盘
function zp_ani(ele, deg) {
    var rote = 60;
    if (deg == 1) {
        rote = rote;
    } else if (deg == 2) {
        rote = rote * 2;
    } else if (deg == 3) {
        rote = rote * 3;
    } else if (deg == 4) {
        rote = rote * 4;
    } else if (deg == 5) {
        rote = rote * 5;
    } else if (deg == 6) {
        rote = rote * 6;
    }
    Zepto(ele).css({
        "-webkit-transform": "rotateZ(" + (5 * 360 + rote) + "deg)"
    });

}


function loadjd(ele, plv) {
    var s;
    timer = setInterval(function() {
        s = parseInt(Zepto(ele).text());
        s = s + 1;
        Zepto(ele).text(s);
        if (s == 100) {
            clearInterval(timer);
            setTimeout(function() {
                loaded();
            }, 1500);

        }
        console.log(s);
    }, plv);
}

//在一定范围产生随机数
function GetRandomNum(Min, Max) {
    var Range = Max - Min;
    var Rand = Math.random();
    return (Min + Math.round(Rand * Range));
}


function getInner() { //获取窗口款高度
    if (typeof window.innerWidth != "undefined") {
        return {
            width: window.innerWidth,
            height: window.innerHeight
        }
    } else {
        return {
            width: document.documentElement.clientWidth,
            height: document.documentElement.clientHeight
        }
    }
}

function getScroll() { //获取滚动条
    return {
        top: document.documentElement.scrollTop || document.body.scrollTop,
        left: document.documentElement.scrollLeft || document.body.scrollLeft,
        width: document.documentElement.scrollWidth || document.body.scrollWidth,
        height: document.documentElement.scrollHeight || document.body.scrollHeight
    }
}


function getArrayItems(arr, num) { ////从一个给定的数组arr中,随机返回num个不重复项
    //新建一个数组,将传入的数组复制过来,用于运算,而不要直接操作传入的数组;
    var temp_array = new Array();
    for (var index in arr) {
        temp_array.push(arr[index]);
    }
    //取出的数值项,保存在此数组
    var return_array = new Array();
    for (var i = 0; i < num; i++) {
        //判断如果数组还有可以取出的元素,以防下标越界
        if (temp_array.length > 0) {
            //在数组中产生一个随机索引
            var arrIndex = Math.floor(Math.random() * temp_array.length);
            //将此随机索引的对应的数组元素值复制出来
            return_array[i] = temp_array[arrIndex];
            //然后删掉此索引的数组元素,这时候temp_array变为新的数组
            temp_array.splice(arrIndex, 1);
        } else {
            //数组中数据项取完后,退出循环,比如数组本来只有10项,但要求取出20项.
            break;
        }
    }
    return return_array;
}

function isIosOrAndroid() { //判断安卓还是IOS
    var u = navigator.userAgent,
        app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    alert('是否是Android：' + isAndroid);
    alert('是否是iOS：' + isiOS);
}


function devicemotion() { //移动端重力感应事件
    window.addEventListener("devicemotion", function(event) {
        var eventaccelerationIncludingGravity = event.accelerationIncludingGravity;

        if (eventaccelerationIncludingGravity.x < -1) {
            jQuery('#legt').text('右');
        } else if (eventaccelerationIncludingGravity.x > 1) {
            jQuery('#legt').text('左');
        }

    }, false);
}


function IsPC() { //判断是否为PC端访问
    var userAgentInfo = navigator.userAgent;
    var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
    var flag = "PC";
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            console.log(Agents[v]);
            if (Agents[v] == "iPad") {
                flag = "iPad";
            } else {
                flag = "mobile";
            }
            break;

        }
    }
    return flag;
}


function ssjcHS(sh, hs) { //判断横竖屏
    var supportOrientation = (typeof window.orientation === 'number' && typeof window.onorientationchange === 'object');
    var init = function() {
        var orientation;
        var updateOrientation = function() {
            if (supportOrientation) {
                orientation = window.orientation;
                switch (orientation) {
                    case 90:
                    case -90:
                        orientation = 'landscape';
                        break;
                    default:
                        orientation = 'portrait';
                        break;
                }
            } else {
                orientation = (window.innerWidth > window.innerHeight) ? 'landscape' : 'portrait';
            }

            if (orientation == 'portrait') {
                sh();
            } else if (orientation == 'landscape') {
                hs();
            }

        };

        if (supportOrientation) {
            window.addEventListener('orientationchange', updateOrientation, false);
        } else {
            //监听resize事件
            window.addEventListener('resize', updateOrientation, false);
        }
        updateOrientation();
    };
    window.addEventListener('DOMContentLoaded', init, false);
};



function jcHS(shp, hp) {
    if (window.orientation === 180 || window.orientation === 0) {
        // sh();//竖屏
        shp();
    }
    if (window.orientation === 90 || window.orientation === -90) {
        // hs();//横屏
        hp();
    }
    window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
        if (window.orientation === 180 || window.orientation === 0) {
            // sh();//竖屏
            window.location.reload();
        }
        if (window.orientation === 90 || window.orientation === -90) {
            // hs();//横屏
            window.location.reload();
        }
    }, false);
}


function inpit_select(select, input) {
    Zepto(select).change(function() {
        var bal = jQuery(select + "option:selected").text();
        Zepto(input).val(bal);
    });
}


function starFeach(src_h, src_k) { //五星好评
    Zepto(".star").tap(function() {
        Zepto(".star").attr("src", src_h);
        var sy = Zepto(this).index();
        for (var i = sy; i >= 0; i--) {
            Zepto(".star").eq(i).attr("src", src_k);
        }
        if (sy <= 3) {
            Zepto(".pj_con_0").show();
            Zepto(".pj_con_1").hide();
        } else {
            Zepto(".pj_con_0").hide();
            Zepto(".pj_con_1").show();
        }

    });
}


function checkbox(elesrx, src1, src2) { //checkbox选择器
    Zepto(elesrx).attr("flag", 0);
    Zepto(elesrx).tap(function() {
        if (Zepto(this).attr("flag") == 0) {
            Zepto(elesrx).attr("src", src2).attr("flag", 0);
            Zepto(this).attr("src", src1).addClass("checked");
            Zepto(this).attr("flag") == 1;
        }
    });
}


//手百 start

function bddata_init(arrays, mb_con) {
    jQuery(".lies").remove();
    jQuery(".lie_con").text("");
    for (var i = 0; i <= arrays.lies.length - 1; i++) {
        jQuery(mb_con).append("<div class='lies' firstLev=" + arrays.lies[i].firstLev + " secondLev=" + arrays.lies[i].secondLev + "  caseSce=" + arrays.lies[i].caseSce + " opModule=" + arrays.lies[i].opModule + "><a target='_blank' href=" + arrays.lies[i].aHref + "><img src=" + arrays.lies[i].imgSrc + " class='img_zz' alt=''></a><div class='ts_text text-overflow' title=" + arrays.lies[i].describe + ">" + arrays.lies[i].describe + "</div></div>");
    }
}

function remove_maright(ele) {
    jQuery(ele).each(function() {
        if ((jQuery(this).index() + 1) % 4 == 0) {
            jQuery(this).css({
                "margin-right": 0
            });
        }
    });
}



function firstLev_init(arrays, select_con) {
    for (var i = 0; i <= arrays.data.length - 1; i++) {
        jQuery(select_con).append("<option>" + arrays.data[i].firstLev + "</option>");
    }
}

function secondLev_init(arrays, select_con) {
    for (var i = 0; i <= arrays.data.length - 1; i++) {
        jQuery(select_con).append("<option>" + arrays.data[i].secondLev + "</option>");
    }
}

function opModule_init(arrays, select_con) {
    for (var i = 0; i <= arrays.data.length - 1; i++) {
        jQuery(select_con).append("<option>" + arrays.data[i].opModule + "</option>");
    }
}

function caseSce_init(arrays, select_con) {
    for (var i = 0; i <= arrays.data.length - 1; i++) {
        jQuery(select_con).append("<option>" + arrays.data[i].caseSce + "</option>");
    }
}


function fLevToSlv(flv, slv, array) {
    var isInit = 0;
    jQuery(flv).change(function() {
        if (isInit == 1) {
            secondLev_init(array, slv);
        }
        isInit = 1;
        jQuery(slv + " option").each(function() {
            if (jQuery(this).index() != 0 && jQuery(this).attr("flag") != jQuery(flv + " option:selected").val()) {
                jQuery(this).remove();
            }
        });
    });
}



function slvToFlv(slv, flv) {
    jQuery(slv).change(function() {
        if (jQuery(this).find("option:selected").index() == 0) {
            jQuery(flv + " option").eq(0).attr("selected", "selected")
        } else {
            jQuery(flv + " option").each(function() {
                if (jQuery(this).val() == jQuery(slv + " option:selected").attr("flag")) {
                    jQuery(this).attr("selected", "selected");
                }
            });
        }

    });
}


function casModule(cas, gai, opm, op) {
    jQuery(cas).change(function() {
        var va = jQuery(cas + " option:selected").val();
        if (va == "快速上手") {
            jQuery(gai).show();
            jQuery(opm + " option").each(function() {
                if (jQuery(this).val() != "优化模块") {
                    jQuery(this).remove();
                }
            });

        } else {
            jQuery(gai).hide();
            opModule_init(op, opm);
        }
    });
}


function c_data(sel, lies, res) {

    jQuery(".sel").change(function() {

        bddata_init(res, ".lie_con"); //列报数据初始化 

        jQuery(sel).each(function() {
            var ssy = jQuery(this).find("option:selected").val();
            if (ssy != "投放行业" && jQuery(this).index() == 0) {
                jQuery(lies).each(function() {
                    if (jQuery(this).attr("firstLev") != ssy) {
                        jQuery(this).remove();
                    }
                });
            } else if (ssy != "投放模式" && jQuery(this).index() == 1) {
                jQuery(lies).each(function() {
                    if (jQuery(this).attr("secondLev") != ssy) {
                        jQuery(this).remove();
                    }
                });
            } else if (ssy != "应用场景" && jQuery(this).index() == 2) {
                jQuery(lies).each(function() {
                    if (jQuery(this).attr("casesce") != ssy) {
                        jQuery(this).remove();
                    }
                });
            } else if (ssy != "优化模块" && jQuery(this).index() == 3) {
                jQuery(lies).each(function() {
                    if (jQuery(this).attr("opmodule") != ssy) {
                        jQuery(this).remove();
                    }
                });
            }
        });


        jQuery(lies).attr("style", "");
        remove_maright(lies); //去右边距

        if (jQuery(lies).length == 0) {
            jQuery(".lie_con").text("暂无相关数据！");
        }

        if (jQuery(lies).length <= 4) {
            jQuery(".footer").addClass("flfoot");
        } else {
            jQuery(".footer").removeClass("flfoot");
        }


    });

}



/**数组根据数组对象中的某个属性值进行排序的方法 
 * 使用例子：newArray.sort(sortBy('number',false)) //表示根据number属性降序排列;若第二个参数不传递，默认表示升序排序
 * @param attr 排序的属性 如number属性
 * @param rev true表示升序排列，false降序排序
 * */
function sortBy(attr, rev) {
    //第二个参数没有传递 默认升序排列
    if (rev == undefined) {
        rev = 1;
    } else {
        rev = (rev) ? 1 : -1;
    }

    return function(a, b) {
        a = a[attr];
        b = b[attr];
        if (a < b) {
            return rev * -1;
        }
        if (a > b) {
            return rev * 1;
        }
        return 0;
    }
}


/**
 *时间转时间戳
 */
/*获取指定时间的时间戳 兼容IE*/
function transdate(endTime) {
    var date = new Date();
    date.setFullYear(endTime.substring(0, 4));
    date.setMonth(endTime.substring(5, 7) - 1);
    date.setDate(endTime.substring(8, 10));
    date.setHours(endTime.substring(11, 13));
    date.setMinutes(endTime.substring(14, 16));
    date.setSeconds(endTime.substring(17, 19));
    return Date.parse(date) / 1000;
}


function qkg() {

    alert(str.replace(/\[|]/g, '')); //移除字符串中的所有[]括号（不包括其内容）
    alert(str.replace(/\[.*?\]/g, '')); //移除字符串中的所有[]括号（包括其内容）

}



//将时间戳转换成日期格式：

function timestampToTime(timestamp,flag) {
        var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = date.getDate() + ' ';
        h = date.getHours() + ':';
        m = date.getMinutes() + ':';
        s = date.getSeconds();
        // return Y+M+D+h+m+s;
        if(flag==0){
          return Y+M+D;
        }else if(flag==1){
          return h+m+s;
        }
}

function timestampToTimes(timestamp) {
        var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = date.getDate() + ' ';
        h = date.getHours() + ':';
        m = date.getMinutes() + ':';
        s = date.getSeconds();
        return Y+M+D+h+m+s;
}

// timestampToTime(1403058804);




//手百 end



//二进制流文件转换为base64
function getBase64Image(img) {
    var canvas = document.createElement("canvas");
    canvas.width = img.width;
    canvas.height = img.height;
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0, img.width, img.height);
    var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
    var dataURL = canvas.toDataURL("image/" + ext);
    return dataURL;
}


//base64转换为二进制流文件
function dataURLtoBlob(dataurl) {
    var arr = dataurl.split(','),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], {
        type: mime
    });
}

//base64加密解密

// //1.加密
// var str = '124中文内容';
// var base = new Base64();
// var result = base.encode(str);
// //document.write(result);
 
// //2.解密
// var result2 = base.decode(result);

function Base64() {
 
    // private property
    _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 
    // public method for encoding
    this.encode = function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        input = _utf8_encode(input);
        while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output +
            _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
            _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
        }
        return output;
    }
 
    // public method for decoding
    this.decode = function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;
        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
        while (i < input.length) {
            enc1 = _keyStr.indexOf(input.charAt(i++));
            enc2 = _keyStr.indexOf(input.charAt(i++));
            enc3 = _keyStr.indexOf(input.charAt(i++));
            enc4 = _keyStr.indexOf(input.charAt(i++));
            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;
            output = output + String.fromCharCode(chr1);
            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }
        }
        output = _utf8_decode(output);
        return output;
    }
 
    // private method for UTF-8 encoding
    _utf8_encode = function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
 
        }
        return utftext;
    }
 
    // private method for UTF-8 decoding
    _utf8_decode = function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while ( i < utftext.length ) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            } else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
}


/**
 *
 * @desc 判断两个数组是否相等
 * @param {Array} arr1
 * @param {Array} arr2
 * @return {Boolean}
 */
function arrayEqual(arr1, arr2) {
    // 首先要判断是否是数组,传进来的非数组,返回false
    if (!(arr1 instanceof Array) || !(arr2 instanceof Array)) {
        return false;
    }
    if (arr1 === arr2) return true;
    if (arr1.length != arr2.length) return false;
    for (var i = 0; i < arr1.length; ++i) {
        if (arr1[i] !== arr2[i]) return false;
    }
    return true;
}

// function lubozj(){

//     $('.slider1').bxSlider({

//         slideWidth: 150,

//         minSlides: 2,

//         maxSlides: 2,

//         moveSlides: 1,

//         slideMargin: 10

//   });

//     $('.slider2').bxSlider({

//         slideWidth: 150,

//         minSlides: 2,

//         maxSlides: 2,

//         moveSlides: 1,

//         slideMargin: 10

//   });

//     $('.slider3').bxSlider({

//         slideWidth: 150,

//         minSlides: 2,

//         maxSlides: 2,

//         moveSlides: 1,

//         slideMargin: 10

//   });

//     $('.slider4').bxSlider({

//         slideWidth: 150,

//         minSlides: 2,

//         maxSlides: 2,

//         moveSlides: 1,

//         slideMargin: 10

//   });

// }

/**
*  判断字符长度(汉字算两个)
**/
function strlen(str){
    var len = 0;
    for (var i=0; i<str.length; i++) { 
     var c = str.charCodeAt(i); 
    //单字节加1 
     if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 
       len++; 
     } 
     else { 
      len+=2; 
     } 
    } 
    return len;
}


/**
*检查是否有汉字
*/
function CheckChinese(val){ 
　　var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
　　if(reg.test(val)){
     return true;
   }else{
     return false;
   }

}



function CheckAllChinese(val){
        var reg = new RegExp("[\\u4E00-\\u9FFF]+$","g");
        if(!reg.test(val)){
            console.log('不是纯中文字符');
            return false;
        }else{
            console.log('是纯中文字符');
            return true;
        }
}


function checkAz(string){
    var p = /[a-z]/i; 
    var b = p.test(string);//true,说明有英文字母
    if(b){
        return true;
    }else{
        return false;
    }
}


function check09(string){
    var p = /[0-9]/; 
    var b = p.test(string);//true,说明有数字
    if(b){
     return true;
    }else{
        return false;
    }
}


function checkAz09(string){
    var p = /[0-9a-z]/i; 
    var b = p.test(string);//true,说明有英文字母或数字
    if(b){
       return true;
    }else{
       return false;
    }
}


function checkAzNum(value) {   //判断字符串是否为字母或数字组成
    var Regx = /^[A-Za-z0-9]*$/;
    if (Regx.test(value)) {
        return true;
    }
    else {
        return false;
    }
}



/**
 * @desc 获取浏览器类型和版本
 * @return {String}
 */
function getExplore() {
    var sys = {},
        ua = navigator.userAgent.toLowerCase(),
        s;
    (s = ua.match(/rv:([\d.]+)\) like gecko/)) ? sys.ie = s[1]:
        (s = ua.match(/msie ([\d\.]+)/)) ? sys.ie = s[1] :
        (s = ua.match(/edge\/([\d\.]+)/)) ? sys.edge = s[1] :
        (s = ua.match(/firefox\/([\d\.]+)/)) ? sys.firefox = s[1] :
        (s = ua.match(/(?:opera|opr).([\d\.]+)/)) ? sys.opera = s[1] :
        (s = ua.match(/chrome\/([\d\.]+)/)) ? sys.chrome = s[1] :
        (s = ua.match(/version\/([\d\.]+).*safari/)) ? sys.safari = s[1] : 0;

    // 根据关系进行判断
    if (sys.ie) return ('IE: ' + sys.ie);
    if (sys.edge) return ('EDGE: ' + sys.edge);
    if (sys.firefox) return ('Firefox: ' + sys.firefox);
    if (sys.chrome) return ('Chrome: ' + sys.chrome);
    if (sys.opera) return ('Opera: ' + sys.opera);
    if (sys.safari) return ('Safari: ' + sys.safari);
    return 'Unkonwn';
}

/**
 *
 * @desc 获取操作系统类型
 * @return {String}
 */
function getOS() {
    var userAgent = 'navigator' in window &&
        'userAgent' in navigator &&
        navigator.userAgent.toLowerCase() || '';
    var vendor = 'navigator' in window &&
        'vendor' in navigator &&
        navigator.vendor.toLowerCase() || '';
    var appVersion = 'navigator' in window &&
        'appVersion' in navigator &&
        navigator.appVersion.toLowerCase() || '';

    if (/mac/i.test(appVersion))
        return 'MacOSX';
    if (/win/i.test(appVersion))
        return 'windows';
    if (/linux/i.test(appVersion))
        return 'linux';
    if (/iphone/i.test(userAgent) || /ipad/i.test(userAgent) || /ipod/i.test(userAgent))
        return 'ios';
    if (/android/i.test(userAgent))
        return 'android';
    if (/win/i.test(appVersion) && /phone/i.test(userAgent))
        return 'windowsPhone';
}

/**
 * @desc 深拷贝，支持常见类型
 * @param {Any} values
 */
function deepClone(values) {
    var copy;

    // Handle the 3 simple types, and null or undefined
    if (null == values || "object" != typeof values) return values;

    // Handle Date
    if (values instanceof Date) {
        copy = new Date();
        copy.setTime(values.getTime());
        return copy;
    }

    // Handle Array
    if (values instanceof Array) {
        copy = [];
        for (var i = 0, len = values.length; i < len; i++) {
            copy[i] = deepClone(values[i]);
        }
        return copy;
    }

    // Handle Object
    if (values instanceof Object) {
        copy = {};
        for (var attr in values) {
            if (values.hasOwnProperty(attr)) copy[attr] = deepClone(values[attr]);
        }
        return copy;
    }

    throw new Error("Unable to copy values! Its type isn't supported.");
}

/**
 *
 * @desc   判断`obj`是否为空
 * @param  {Object} obj
 * @return {Boolean}
 */
function isEmptyObject(obj) {
    if (!obj || typeof obj !== 'object' || Array.isArray(obj))
        return false
    return !Object.keys(obj).length
}


/**
 用H5设置本地缓存 localstorage;
**/


function setStorage(obj,val){
    if(window.localStorage){
        var storage = window.localStorage;
        if(getStorage(obj)!=""){
          storage.removeItem(obj);
        }
        storage.setItem(obj,val);//设置b为"isaac" 
    }else{
       console.log('This browser does NOT support localStorage');
    }
}

function getStorage(obj){
    var b;
    if(window.localStorage){
        b = localStorage.getItem(obj);//获取b的值
    }else{
       console.log('This browser does NOT support localStorage');
    }
    return b;
}


function delStorage(obj){
    if(window.localStorage){
       localStorage.removeItem(obj);//清除c的值
    }else{
       console.log('This browser does NOT support localStorage');
    }
}


//返回上一页时强制刷新返回页
function mobileQzsx(){
    window.addEventListener('pageshow', function( e ){  if (e.persisted) {  window.location.reload()  }}); 
}


/*
*验证是否登录(投友圈)
*/
function isLogin(){
       
       // console.log(window.localStorage.length);
       // console.log(getStorage("mobileNo"));
       // console.log(getStorage("passwd"));
       // console.log(getStorage("apiToken"));
       if(!getStorage("mobileNo") || !getStorage("passwd") || !getStorage("apiToken")){
           alert("请登录！");
           window.location.href="login.html";
       }else{
           var dataSend=md5("{'userName': '"+getStorage("mobileNo")+"','passwd': '"+getStorage("passwd")+"'}"+apiKey);
           Zepto.ajax({
                          headers:{
                                    'Accept':'application/json;charset=utf-8',
                                    'sign':dataSend,
                                    'apiToken':"12345667"  //getStorage("apiToken")
                          },
                          type: 'POST',
                          url: serverPath+'jsp/user/userLogin',
                          contentType: 'application/json',
                          dataType:"json",
                          data: "{'userName': '"+getStorage("mobileNo")+"','passwd': '"+getStorage("passwd")+"'}",
                          success: function(data,textStatus,request){
                              if(data.code==1000){
                                 var result=JSON.stringify(data);
                                     result=md5(result+apiKey);
                                 var sign = request.getResponseHeader("sign");
                                 if(result==sign){
                                    console.log("接口安全！");
                                    if(getStorage("apiToken")===data.data.apiToken){
                                        console.log("验证为登录状态！");
                                    }
                                 }else{
                                    window.location.href="login.html";
                                 }
                              }
                          },
                          error: function(XMLHttpRequest, textStatus, errorThrown){
                               var responseText=JSON.parse(XMLHttpRequest.responseText);
                               window.location.href="login.html";
                          }
                });
       }
       
       
    

}





/**
 *
 * @desc 生成指定范围随机数
 * @param  {Number} min
 * @param  {Number} max
 * @return {Number}
 */
function randomNum(min, max) {
    return Math.floor(min + Math.random() * (max - min));
}


//判断是否是微信浏览器的函数
function isWeiXin(){
  //window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息，这个属性可以用来判断浏览器类型
  var ua = window.navigator.userAgent.toLowerCase();
  //通过正则表达式匹配ua中是否含有MicroMessenger字符串
  if(ua.match(/MicroMessenger/i) == 'micromessenger'){
  return true;
  }else{
  return false;
  }
}

/**
 *
 * @desc 随机生成颜色
 * @return {String}
 */
function randomColor() {
    return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
}

/**
 *
 * @desc   现金额转大写
 * @param  {Number} n
 * @return {String}
 */
function digitUppercase(n) {
    var fraction = ['角', '分'];
    var digit = [
        '零', '壹', '贰', '叁', '肆',
        '伍', '陆', '柒', '捌', '玖'
    ];
    var unit = [
        ['元', '万', '亿'],
        ['', '拾', '佰', '仟']
    ];
    var head = n < 0 ? '欠' : '';
    n = Math.abs(n);
    var s = '';
    for (var i = 0; i < fraction.length; i++) {
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
    }
    s = s || '整';
    n = Math.floor(n);
    for (var i = 0; i < unit[0].length && n > 0; i++) {
        var p = '';
        for (var j = 0; j < unit[1].length && n > 0; j++) {
            p = digit[n % 10] + unit[1][j] + p;
            n = Math.floor(n / 10);
        }
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
    }
    return head + s.replace(/(零.)*零元/, '元')
        .replace(/(零.)+/g, '零')
        .replace(/^整$/, '零元整');
}

/**
 *
 * @desc   判断是否为邮箱地址
 * @param  {String}  str
 * @return {Boolean}
 */
function isEmail(str) {
    return /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(str);
}

/**
 *
 * @desc   判断是否为手机号
 * @param  {String|Number} str
 * @return {Boolean}
 */
function isPhoneNum(str) {
    return /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(str)
}


//本地储存数据
function setLocalStorage(key, value, callback, flag) {
    //临时本地储存
    if (flag) {
        sessionStorage.setItem(key, value);
    }
    //永久本地储存
    else {
        localStorage.setItem(key, value);
    }
    //执行回调函数
    if ($.type(callback) == 'function') {
        callback()
    }
}
//读取本地信息
function getLocalStorage(key, callback, flag) {
    var data = null;
    //读取临时数据
    if (flag) {
        data = sessionStorage.getItem(key);
    }
    //读取永久数据
    else {
        data = localStorage.getItem(key);
    }
    //执行回调函数
    if ($.type(callback) == 'function') {
        callback(data)
    }
}
//移除数据
function removeLocaLStorage(key, callback, flag) {
    if (flag) {
        sessionStorage.removeItem(key);
    } else {
        localStorage.removeItem(key);
    }
    //执行回调函数
    if ($.type(callback) == 'function') {
        callback()
    }
}


//概率计算
function prob(){

    var ran=Math.ceil(Math.random()*100)     //外层100以内的随机整数

    if(ran<=65){  //通过概率判断选取数字

        var needNum= getRandomInt(9,11);    
        return needNum;

    }else if(ran>65 && ran<=85){

        var needNum= getRandomInt(1,3);   
        return needNum;

    }else if(ran>85 && ran<=95){

        var needNum= getRandomInt(3,6); 
        return needNum;

    }else if(ran>95 && ran<=99){

        var needNum= getRandomInt(6,8);  
        return needNum;

    }else if(ran>99 && ran<=100){

        var needNum= 8  
        return needNum;

    }
}

//随机产生指定范围的数值
function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min)) + min; //不含最大值，含最小值
}


//获取当前周日期范围
function getWeek(fflag,lflag) {
	this.nowTime = new Date();
	this.init = function() {
		this.dayInWeek = this.nowTime.getDay();
		this.dayInWeek == 0 && (this.dayInWeek = 7);
		this.thsiWeekFirstDay = this.nowTime.getTime() - (this.dayInWeek - 1) * 86400000;
		this.thisWeekLastDay = this.nowTime.getTime() + (7 - this.dayInWeek) * 86400000;
		return this;
	};
	this.getWeekType = function(type) {
		type = ~~type;
		var firstDay = this.thsiWeekFirstDay + type * 7 * 86400000;
		var lastDay = this.thisWeekLastDay + type * 7 * 86400000;
		return this.getWeekHtml(firstDay, lastDay);
	}
	this.formateDate = function(time) {
		var newTime = new Date(time)
		var year = newTime.getFullYear();
		var month = newTime.getMonth() + 1;
		var day = newTime.getDate();
		return year + "-" + (month >= 10 ? month : "0" + month) + "-" + (day >= 10 ? day : "0" + day);
	};
	this.getWeekHtml = function(f, l) {
		if(fflag == true){
			return this.formateDate(f);
		}else if(lflag == true){
			return this.formateDate(l);
		}else{
			return this.formateDate(f) + "至" + this.formateDate(l);
		}
		
	};
}
var getWeek = new getWeek(false,true);
var week = getWeek.init().getWeekType();
// console.log("本周日期范围");
// console.log(week);



//获取本年内的第一天和最后一天
function getYearFirstLast(first,last){
	var myDate = new Date();
	if(first == true && last == false){
		return myDate.getFullYear()+"-01-01";
	}else if(first == false && last == true){
		return myDate.getFullYear()+"-12-31";
	}
}
// console.log(getYearFirstLast(true,false));
// console.log(getYearFirstLast(false,true));



//获取当前月份的第一天
function getCurrentMonthFirst(){
	var date = new Date();
	date.setDate(1);
	var month = parseInt(date.getMonth()+1);
	var day = date.getDate();
	if (month < 10) {
		month = '0' + month
	}
	if (day < 10) {
		day = '0' + day
	}
	return date.getFullYear() + '-' + month + '-' + day;
}
//获取当前月份的最后一天
function getCurrentMonthLast(){
	var date=new Date();
	var currentMonth=date.getMonth();
	var nextMonth=++currentMonth;
	var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);
	var oneDay=1000*60*60*24;
	var lastTime = new Date(nextMonthFirstDay-oneDay);
	var month = parseInt(lastTime.getMonth()+1);
	var day = lastTime.getDate();
	if (month < 10) {
		month = '0' + month
	}
	if (day < 10) {
		day = '0' + day
	}
	return date.getFullYear() + '-' + month + '-' + day;
}
// console.log(getCurrentMonthFirst());
// console.log(getCurrentMonthLast());


//获取当前日期
function getCurrentDate(){
	var d = new Date(),
		str = '';
		str += d.getFullYear() + '-'; //获取当前年份 
		str += (d.getMonth() > 9 ? d.getMonth() : "0"+(d.getMonth()+ 1)) + '-'; //获取当前月份（0——11） 
		str += d.getDate() > 9 ? d.getDate() :  "0"+d.getDate();
		// str += d.getHours() + '时';
		// str += d.getMinutes() + '分';
		// str += d.getSeconds() + '秒';
	return str;
}
// console.log(getCurrentDate());

function carousel(ele){
   var carousel = jQuery(ele).waterwheelCarousel({
              flankingItems: 2,
              separation:$(window).width()*0.16,
              separationMultiplier:0.8,
              horizonOffset:-5,
              sizeMultiplier:0.88
        });

       Zepto(ele).swipeLeft(function(){
       			carousel.next();
       			setTimeout(function(){
       				jQuery(ele+">div").each(function(){
       					jQuery(this).attr("style",jQuery(this).find("img").attr("style"));
       					jQuery(this).removeClass("carousel-center");
       					jQuery(this).addClass(jQuery(this).find("img").attr("class"));
       					jQuery(this).find("img").attr("style","");
       					jQuery(this).find("img").attr("class","");
						// //头像渐现
						// var that=this;
						// jQuery(this).find(".tx_con").removeClass("fadeIn")
						// setTimeout(function(){
						// 	if(jQuery(that).hasClass("carousel-center")){
						// 		jQuery(that).find(".tx_con").addClass("fadeIn");
						// 	}
						// },200);
       					// 缩放换算
       					jQuery(this).css("transform","scale(1)");
       					jQuery(this).find(".zbs_top .tx_con").css("transform","scale(1) translate(-50%,0)");
       					jQuery(this).find(".techerName").css("bottom","0.19rem");
       					if(jQuery(this).attr("style").indexOf("z-index: 2") != -1){
       						jQuery(this).css("transform","scale(0.85)").css("filter","grayscale(20%)");
       						jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.6) translate(-80%,-50%)");
       						jQuery(this).find(".techerName").css("bottom","1.33rem");
       					}else if(jQuery(this).attr("style").indexOf("z-index: 3") != -1){
       						jQuery(this).css("transform","scale(0.92)").css("filter","grayscale(20%)");
       						jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.8) translate(-50%,0)");
       					}
       					console.log(jQuery(this).index());
       				});
       			},300);
       		});
       		Zepto(ele).swipeRight(function(){
       			carousel.prev();
       			setTimeout(function(){
       				jQuery(ele+">div").each(function(){
       					jQuery(this).attr("style",jQuery(this).find("img").attr("style"));
       					jQuery(this).removeClass("carousel-center");
       					jQuery(this).addClass(jQuery(this).find("img").attr("class"));
       					jQuery(this).find("img").attr("style","");
       					jQuery(this).find("img").attr("class","");
						// //头像渐现
						// var that=this;
						// jQuery(this).find(".tx_con").removeClass("fadeIn")
						// setTimeout(function(){
						// 	if(jQuery(that).hasClass("carousel-center")){
						// 		jQuery(that).find(".tx_con").addClass("fadeIn");
						// 	}
						// },200);
       					// 缩放换算
       					jQuery(this).css("transform","scale(1)");
       					jQuery(this).find(".techerName").css("bottom","0.19rem");
       					jQuery(this).find(".zbs_top .tx_con").css("transform","scale(1) translate(-50%,0)");
       					if(jQuery(this).attr("style").indexOf("z-index: 2") != -1){
       						jQuery(this).css("transform","scale(0.85)").css("filter","grayscale(20%)");
       						jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.6) translate(-80%,-50%)");
       						jQuery(this).find(".techerName").css("bottom","1.33rem");
       					}else if(jQuery(this).attr("style").indexOf("z-index: 3") != -1){
       						jQuery(this).css("transform","scale(0.92)").css("filter","grayscale(20%)");
       						jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.8) translate(-50%, 0)");
       					}
       					console.log(jQuery(this).index());
       				});
       			},300);
       		});
       		setTimeout(function(){
       			jQuery(ele+">div").each(function(){
       				jQuery(this).attr("style",jQuery(this).find("img").attr("style"));
       				jQuery(this).removeClass("carousel-center");
       				jQuery(this).addClass(jQuery(this).find("img").attr("class"));
       				jQuery(this).find("img").attr("style","");
       				jQuery(this).find("img").removeClass("");
					// //头像渐现
					// var that=this;
					// jQuery(this).find(".tx_con").removeClass("fadeIn")
					// setTimeout(function(){
					// 	if(jQuery(that).hasClass("carousel-center")){
					// 		jQuery(that).find(".tx_con").addClass("fadeIn");
					// 	}
					// },200);
       				// 缩放换算
       				jQuery(this).css("transform","scale(1)");
       				jQuery(this).find(".zbs_top .tx_con").css("transform","scale(1) translate(-50%,0)");
       				jQuery(this).find(".techerName").css("bottom","0.19rem");
       				if(jQuery(this).attr("style").indexOf("z-index: 2") != -1){
       					jQuery(this).css("transform","scale(0.85)").css("filter","grayscale(20%)");
       					jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.6) translate(-60%,-50%)");
       					jQuery(this).find(".techerName").css("bottom","1.33rem");
       				}else if(jQuery(this).attr("style").indexOf("z-index: 3") != -1){
       					jQuery(this).css("transform","scale(0.92)").css("filter","grayscale(20%)");
       					jQuery(this).find(".zbs_top .tx_con").css("transform","scale(0.8) translate(-50%,0)");
       				}
       				console.log(jQuery(this).index());
       			});
       		},1000);
       		
       		

        // $('#reload').bind('click', function () {
        //   newOptions = eval("(" + $('#newoptions').val() + ")");
        //   carousel.reload(newOptions);
        //   return false;
        // });
		
}


//最新直播
function liveDataInit(data){
	for (var i = 0; i < data.length; i++) {
			Zepto(".box_3d_lie").eq(data[i].tapId-1).find("#carousel").append(
				'<div class="abs" href="'+ data[i].url +'"><img src="img/p6_lunbo01.png" id="opc0" class="opc0">' +
					'<div class = "zbs_top abs" >' +
						'<div class = "zbs_tit abs" > '+ data[i].liveTime +'</div>' +
						'<div class = "tx_con auto_cenp animated" >' +
						   '<img src = "img/'+ data[i].txImageName +'" id = "head" />' +
					    '</div>' +
					    '<div class = "techerName abs" ><span>'+data[i].lecturer+' </span></div>' +
					'</div>' +
					'<div class = "zbs_bottom abs">' +
						'<div class = "jsjs wraps"> '+ data[i].currName  +' </div> ' +
						'<div class = "jslb abs"> '+ data[i].categoryName +' </div> ' +
					'</div>' +
				'</div>');
				
				//节点数奇偶处理（插件兼容）
				if(i == (data.length-1)){
					Zepto(".box_3d_lie").each(function(){
						if(Zepto(this).find("#carousel>div").length<5){
							if(Zepto(this).find("#carousel>div").length==4){
								Zepto(this).find("#carousel>div").eq(2).clone(true).appendTo(Zepto(this).find("#carousel"));
							}else if(Zepto(this).find("#carousel>div").length==3){
								Zepto(this).find("#carousel>div").eq(1).clone(true).appendTo(Zepto(this).find("#carousel"));
								Zepto(this).find("#carousel>div").eq(2).clone(true).appendTo(Zepto(this).find("#carousel"));
							}
						}else if(Zepto(this).find("#carousel>div").length>5){
							if(Zepto(this).find("#carousel>div").length%2 == 0){
								Zepto(this).find("#carousel>div").eq(Zepto(this).find("#carousel>div").length/2).clone(true).appendTo(Zepto(this).find("#carousel"));
							}
						}
					});
					
					//3d轮播初始化
					carousel(".carousel_1");
					carousel(".carousel_2");
					carousel(".carousel_3");
				}
				
		}
}
// 精品课程
function tapIdInitData(arry,eleindex){
	var pophs1="show";
	var pophs2="show";
	for (var i = arry.length; i > 0; i--) {
		if(arry[i-1].pop1 == ""){
			pophs1="hide";
		}
		if(arry[i-1].pop2 == ""){
			pophs2="hide";
		}
		Zepto(".bouclass_neno_lie").eq(eleindex).append(
				'<a href="'+arry[i-1].url+'" target="_blank"><div class = "bouclass_neno_mb res">'+
					'<img src = "img/'+arry[i-1].txImageName+'" class = "bouc_tx auto_cens" />'+
					'<div class = "bouc_js flo_r">'+
						'<div class = "bouc_js_tit wraps bold" > '+arry[i-1].boucClassName+' </div>'+
						'<div class = "bounc_name" > 讲师: '+arry[i-1].lecturer+' </div>'+
						'<div style="width:7rem;position:absolute;z-index:99999;left:0;bottom:-0.22rem">'+
						'<div class = "bounc_bq_lie" > 课程时长:'+arry[i-1].classLong+' 分钟 </div>'+
						'<div class = "bounc_bq_lie '+pophs1+'" > '+arry[i-1].pop1+' </div>'+ 
						'<div class = "bounc_bq_lie '+pophs2+'"> '+arry[i-1].pop2+' </div>'+ 
						'</div>'+
					'</div>'+
					'<img src = "img/bouc_icon.png" class = "bouc_icon auto_cens" >'+
				'</div></a>'
		);
	}
}

function getCurrentTime(){
    var today = new Date();
    var year = today.getFullYear();
    var month = today.getMonth() + 1;
    var day = today.getDate();
    var hours = today.getHours();
    var minutes = today.getMinutes();
    var seconds = today.getSeconds();
    var formattedTime = year + "年" +
        (month < 10 ? "0" : "") + month + "月" +
        (day < 10 ? "0" : "") + day + "日 " +
        (hours < 10 ? "0" : "") + hours + "点" +
        (minutes < 10 ? "0" : "") + minutes + "分" +
        (seconds < 10 ? "0" : "") + seconds + "秒";
    return formattedTime;
}


/*
js中面向对象四种的写法

第一种：

function Circle(r) {   
      this.r = r;   
}   
Circle.PI = 3.14159;   
Circle.prototype.area = function() {   
  return Circle.PI * this.r * this.r;   
}   
  
var c = new Circle(1.0);      
alert(c.area());   

第二种：

var Circle = function() {   
   var obj = new Object();   
   obj.PI = 3.14159;   
      
   obj.area = function( r ) {   
       return this.PI * r * r;   
   }   
   return obj;   
}   
  
var c = new Circle();   
alert( c.area( 1.0 ) );  
第三种：

var Circle={   
   "PI":3.14159,   
 "area":function(r){   
          return this.PI * r * r;   
        }   
};   
alert( Circle.area(1.0) );  

第四种：

var Circle = new Object();   
Circle.PI = 3.14159;   
Circle.Area = function( r ) {   
       return this.PI * r * r;   
}   
  
alert( Circle.Area( 1.0 ) ); 


this的指向问题：

1、当this在事件处理函数中时，this是事件源（this对象时自动产生的）；

2、this在某个对象的函数内部时，this表示该函数的所属对象；

3、当this所在的函数没有明确的对象时。this是window对象；

4、当this在构造函数内部时，this是new出来的对象
*/

// console.log(a);

// var a = 3;

// var a;
// a = 3;